# -*- coding: UTF-8 -*-

# while 循环
print "\n------ while 循环 ------"
count = 0
while (count < 9):
    print "count = ", count
    count += 1
print "bey bey"

# 循环使用 else 语句
print "\n------ while...else ------"
count = 0
while (count < 9):
    print "count = ", count
    count += 1
else:
    print "end = ", count

# for 循环
print "\n------ for 循环 案例1 ------"
for a in "python":
    print "打印：", a
print "\n------ for 循环 案例2 ------"
list = ["jj", "mm", "ww"]
for item in list:
    print item
# 通过序列索引迭代
print "\n------ for 循环 案例3 ------"
for idx in range(len(list)):  # 函数 len() 返回列表的长度 | range返回一个序列的数
    print list[idx]

# 嵌套循环
print "\n------ 嵌套for循环 ------"
list = ["a", "b", "c"]
list2 = ["1", "2", "3"]
for i in list:
    for j in list2:
        print j
    print i
print "\n------ 嵌套while循环 ------"
i = 0
while (i < 5):
    j = 0
    while (j < 3):
        print j
        j += 1
    print i
    i += 1

# break 语句
print "\n------ break 语句案例1 ------"
count = 0
while 1:
    if (count >= 10): break
    print count
    count += 1
print "\n------ break 语句案例2 ------"
for item in "Python":
    if item == 'h':
        break
    print "获取的数据为：", item

# continue 语句
print "\n------ continue 语句 ------"
count = 0
while (count < 10):
    count += 1
    if (count % 2 > 0): continue
    print count

# 无限循环
print "\n------ 无限循环 ------"
# while 1:  # 该条件永远为true，循环将无限执行下去
#     num = raw_input("Enter a number  :")
#     print "You entered: ", num
# print "Good bye!"

# pass 语句
print "\n------ pass 语句 ------"
for item in "Python":
    if item == "h":
        pass
        print "这是pass块"
    print item
